package nsu.edu.zsq.controller.teacher;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import nsu.edu.zsq.common.JsonData;
import nsu.edu.zsq.common.RequestHolder;
import nsu.edu.zsq.param.StuScoreParam;
import nsu.edu.zsq.param.TchCourseParam;
import nsu.edu.zsq.service.sys.TeacherCourseService;
import nsu.edu.zsq.service.teacher.CourseScoreService;

/** 
* Description: 教师课程的controller类<br>
*/
@RequestMapping("/teacher/course")
@Controller
public class PersonalCourseController {
    
    @Autowired
    private TeacherCourseService teacherCourseService;
    @Autowired
    private CourseScoreService courseScoreService;
    
    /**
     * 跳转到‘个人课表’页面
     * @param model
     * @return String teacher/course/teaCourse_time.html
     */
    @RequestMapping("/toCourseTime")
    public String toCourseTime(Model model) {
        List<TchCourseParam> listTchCourse = teacherCourseService.listTchCourseWithCourseTime(RequestHolder.getCurrentTeacher().getTeacherNo());
        model.addAttribute("listTchCourse", listTchCourse);
        return "teacher/course/teaCourse_time.html";
    }
    
    /**
     * 获取教师重修课程列表
     * @return JsonData
     */
    @RequestMapping("/listRetakeCourse")
    @ResponseBody
    public JsonData listRetakeCourse() {
        List<StuScoreParam> listRetakeCourse = courseScoreService.listRetakeCourse();
        return JsonData.success(listRetakeCourse);
    }
    
    /**
     * 跳转到“重修课程-查看学生”页面
     * @param model
     * @param tchCourseId 教师课程id
     * @return String teacher/course/RetakeCourse_student_list.html
     */
    @RequestMapping("/toRetakeCourse_student_list")
    public String toRetakeCourse_student_list(@RequestParam("tchCourseId")int tchCourseId, Model model) {
        List<StuScoreParam> listStuScoreParam = courseScoreService.listRetakeStudentByTchCourseId(tchCourseId);
        model.addAttribute("listStuScoreParam", listStuScoreParam);
        return "teacher/course/RetakeCourse_student_list.html";
    }
}
